一、代碼說明:
由于數(shù)據(jù)分析需要,按照規(guī)定的上、下限值,剔除數(shù)組中超出上下限的數(shù)據(jù)。
代碼中使用了 C++ 標準庫里?std::list 的函數(shù):remove_if()。非常簡捷明了。
二、代碼實現(xiàn):
/剔除數(shù)組中的無效數(shù)據(jù)
extern "C" __declspec(dllexport) int RemoveInvalidData(double* input, long size_input, double* output, long &size_output) {
?
? ? vector<double> vecTmp(input, input + size_input);
? ? list<double> dataList;
? ? dataList.assign(vecTmp.begin(), vecTmp.end());
?
? ? //剔除超出上下界的數(shù)據(jù)
? ? dataList.remove_if([](double i) { return (i > 28.50 || i < 24.0); });
?
? ? ? ? ......
?
}